<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    width: 200px;
    height: 200px;
    margin: 20px;
    float: left;
    background: yellow;
  }
</style>

<script>
  //let alpha = 30

  window.onload = function () {
    let div1 = document.getElementById("div1")
    let div2 = document.getElementById("div2")
    let div3 = document.getElementById("div3")

    div1.onmouseover = function () {
      startMove(this, "height", 400)
    }
    div1.onmouseout = function () {
      startMove(this, "height", 200)
    }
    div2.onmouseover = function () {
      startMove(this, "width", 400)
    }
    div2.onmouseout = function () {
      startMove(this, "width", 200)
    }

    div3.onmouseover = function () {
      startMove(this, "fontSize", 30)
    }
    div3.onmouseout = function () {
      startMove(this, "fontSize", 20)
    }

  }

  function startMove(obj, attr, target) {
    clearInterval(obj.timer)
    obj.timer = setInterval(() => {
      let cur = parseInt(getStyle(obj, attr))
      let speed = (target - cur) / 6
      speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed)
      if (cur == target) {
        clearInterval(obj.timer)
      } else {
        obj.style[attr] = cur + speed + "px"
      }
    }, 30);
  }

  function getStyle(obj, name) {
    if (obj.currentStyle) {
      return obj.currentStyle[name];
    } else {
      return getComputedStyle(obj, '')[name];
    }
  }
</script>

<body>

  <div id="div1">变高</div>
  <div id="div2">变宽</div>
  <div id="div3">字体变大</div>

</body>

</html>